<#include "/public/macro.html">
<style>
	.layui-form-label{
		width: 140px !important;
	}
</style>
<div class="uk-layui-form">
	<form class="layui-form" action="/admin/multitenant/edit/save.html">
		<input type="hidden" name="id" value="${tenant.id!''}" />
		<input type="hidden" name="currtype" value="${currtype!''}" />
		<div class="layui-collapse">
			<div class="layui-colla-item">
				<h2 class="layui-colla-title">基本信息</h2>
				<div class="layui-colla-content layui-show">
					<div class="layui-form-item">
						<div class="layui-inline">
							<label class="layui-form-label">名称：</label>
							<div class="layui-input-inline">
								<input type="text" name="tenantname" id="tenantname" value="${tenant.tenantname!''}"  lay-verify="required" required class="layui-input" autocomplete="off">
							</div>
						</div>
						<div class="layui-inline">
							<div class="layui-form-item">
								<label class="layui-form-label" >类型：</label>
								<div class="layui-input-inline">
									<select name="type">
										<option value="">请选择</option>
										<#if tenantTypeList?? && tenantTypeList?size gt 0>
											<#list tenantTypeList as type>
												<option value="${type.id!''}" <#if tenant?? && type.id == tenant.type>selected="selected"</#if>>${type.name!''}</option>
											</#list>
										</#if>
									</select>
								</div>
							</div>
						</div>
					</div>

					<div class="layui-form-item">
						<div class="layui-inline">
							<label class="layui-form-label">分类：</label>
							<div class="layui-input-inline">
								<input type="text" name="category" id="category" value="${tenant.category!''}"  class="layui-input" autocomplete="off">
							</div>
						</div>
						<div class="layui-inline">
							<label class="layui-form-label">分组：</label>
							<div class="layui-input-inline">
								<input type="text" name="grouping" id="grouping" value="${tenant.grouping!''}"  class="layui-input" autocomplete="off">
							</div>
						</div>
					</div>

					<div class="layui-form-item">
						<div class="layui-inline">
							<label class="layui-form-label">评价星级：</label>
							<div class="layui-input-inline">
								<input type="text" name="scorestar" id="scorestar" value="${tenant.scorestar!''}" lay-verify="number" class="layui-input" autocomplete="off">
							</div>
						</div>
						<div class="layui-inline">
							<label class="layui-form-label">店铺等级：</label>
							<div class="layui-input-inline">
								<input type="text" name="level" id="level" value="${tenant.level!''}" lay-verify="number" class="layui-input" autocomplete="off">
							</div>
						</div>
					</div>

					<div class="layui-form-item">
						<div class="layui-inline">
							<label class="layui-form-label">主营业务：</label>
							<div class="layui-input-inline">
								<input type="text" name="mainbusiness" id="mainbusiness" value="${tenant.mainbusiness!''}" style="width: 560px;" class="layui-input" autocomplete="off">
							</div>
						</div>
					</div>

					<div class="layui-form-item">
						<div class="layui-inline">
							<label class="layui-form-label">PC店铺地址：</label>
							<div class="layui-input-inline">
								<input type="text" name="pcurl" id="pcurl" value="${tenant.pcurl!''}" class="layui-input" autocomplete="off">
							</div>
						</div>
						<div class="layui-inline">
							<label class="layui-form-label">移动端店铺地址：</label>
							<div class="layui-input-inline">
								<input type="text" name="h5url" id="h5url" value="${tenant.h5url!''}"  class="layui-input" autocomplete="off">
							</div>
						</div>
					</div>
					<div class="layui-form-item" >
						<label class="layui-form-label">店铺描述：</label>
						<div class="layui-input-inline">
							<textarea name="description" placeholder="请输入内容" class="layui-textarea" style="resize:none;width: 560px;" maxlength="300">${tenant.description!''}</textarea>
						</div>
					</div>
				</div>
			</div>
		</div>

		<div class="layui-collapse">
			<div class="layui-colla-item">
				<h2 class="layui-colla-title">联系信息</h2>
				<div class="layui-colla-content layui-show">
					<div class="layui-form-item">
						<div class="layui-inline">
							<label class="layui-form-label" style="width:130px;">所在地区：</label>
							<div class="layui-input-inline" style="width:100px;">
								<input type="hidden" name="provinceText"   class="layui-input" autocomplete="off">
								<@select2 "com.dic.address.area" "province" tenant.province "" "width:100px;" ""  />
							</div>
						</div>
						<div class="layui-inline">
							<input type="hidden" name="cityText"   class="layui-input" autocomplete="off">
							<div class="layui-input-inline" style="width:100px;" id="c_city">
								<@select2 tenant.city+".subdic" "city" tenant.city "" "width:86px;"  "" /><!-- 二级字典，不存在的 CODE -->
							</div>
						</div>
						<div class="layui-inline">
							<input type="hidden" name="countryText"   class="layui-input" autocomplete="off">
							<div class="layui-input-inline" style="width:100px;" id="c_country">
								<@select2 tenant.area+".subdic" "area" tenant.area "" "width:100px;"  ""/><!-- 二级字典，不存在的 CODE -->
							</div>
						</div>
					</div>

					<div class="layui-form-item">
						<label class="layui-form-label">详细地址：</label>
						<div class="layui-input-inline">
							<input type="text" name="addr" id="addr" value="${tenant.addr!''}" style="width: 560px;" class="layui-input" autocomplete="off">
						</div>
					</div>

					<div class="layui-form-item">
						<div class="layui-inline">
							<label class="layui-form-label">联系电话：</label>
							<div class="layui-input-inline">
								<input type="text" name="mobile" id="mobile" value="${tenant.mobile!''}" class="layui-input" autocomplete="off">
							</div>
						</div>
						<div class="layui-inline">
							<label class="layui-form-label">邮箱：</label>
							<div class="layui-input-inline">
								<input type="text" name="mail" id="mail" value="${tenant.mail!''}"  class="layui-input" autocomplete="off">
							</div>
						</div>
					</div>

					<div class="layui-form-item">
						<div class="layui-inline">
							<label class="layui-form-label">QQ：</label>
							<div class="layui-input-inline">
								<input type="text" name="qq" id="qq" value="${tenant.qq!''}"  class="layui-input" autocomplete="off">
							</div>
						</div>
						<div class="layui-inline">
							<label class="layui-form-label">微信号码：</label>
							<div class="layui-input-inline">
								<input type="text" name="wechat" id="wechat" value="${tenant.wechat!''}"  class="layui-input" autocomplete="off">
							</div>
						</div>
					</div>
					<div class="layui-form-item">
						<div class="layui-inline">
							<label class="layui-form-label">阿里旺旺号码：</label>
							<div class="layui-input-inline">
								<input type="text" name="aliwangwang" id="aliwangwang" value="${tenant.aliwangwang!''}" class="layui-input" autocomplete="off">
							</div>
						</div>
					</div>
				</div>
			</div>
		</div>

		<div class="layui-collapse">
			<div class="layui-colla-item">
				<h2 class="layui-colla-title">其他信息</h2>
				<div class="layui-colla-content layui-show">
					<div class="layui-form-item">
						<div class="layui-inline">
							<label class="layui-form-label">标签：</label>
							<div class="layui-input-inline">
								<input type="text" name="tag" id="tag"  value="${tenant.tag!''}" class="layui-input" autocomplete="off">
							</div>
						</div>
					</div>
					<div class="layui-form-item" >
						<label class="layui-form-label">备注：</label>
						<div class="layui-input-inline">
							<textarea name="remark" placeholder="请输入内容" class="layui-textarea" style="resize:none;width: 560px;" maxlength="300">${tenant.remark!''}</textarea>
						</div>
					</div>
				</div>
			</div>
		</div>

		<div class="layui-collapse">
			<div class="layui-colla-item">
				<h2 class="layui-colla-title">系统信息</h2>
				<div class="layui-colla-content layui-show">
					<div class="layui-form-item">
						<div class="layui-inline">
							<label class="layui-form-label">租户ID：</label>
							<div class="layui-input-inline">
								<input type="text" name="tenantcode" id="tenantcode" value="${tenant.tenantcode!''}" required lay-verify="required|tenantcode" placeholder="请输入租户ID" autocomplete="off" class="layui-input">
							</div>
						</div>
						<div class="layui-inline">
							<label class="layui-form-label">文本坐席数量：</label>
							<div class="layui-input-inline">
								<input type="text" name="agentnum" value="${tenant.agentnum!0}"  required lay-verify="required|number" placeholder="-1无限制" autocomplete="off" class="layui-input">
							</div>
						</div>
					</div>

					<div class="layui-form-item">
						<#if models?? && models["callcenter"]?? && models["callcenter"] == true>
						<div class="layui-inline">
							<label class="layui-form-label">呼叫中心坐席数量：</label>
							<div class="layui-input-inline">
								<input type="text" name="callcenteragentnum" value="${tenant.callcenteragentnum!0}"  required lay-verify="required|number" placeholder="-1无限制" autocomplete="off" class="layui-input">
							</div>
						</div>
					</#if>
					<#if models?? && models["calloutai"]?? && models["calloutai"] == true>
					<div class="layui-inline">
						<label class="layui-form-label">电销机器人并发数量：</label>
						<div class="layui-input-inline">
							<input type="text" name="robotagentnum"  value="${tenant.robotagentnum!0}" required lay-verify="required|number" placeholder="-1无限制" autocomplete="off" class="layui-input">
						</div>
					</div>
				</#if>
			</div>

			<div class="layui-form-item">
				<label class="layui-form-label">授权模块：</label>
				<div class="layui-input-inline">
					<textarea name="models" placeholder="授权模块 ，号分隔 （contacts,weixin,workorders,xiaoe,callcenter,sales,calloutai,qc)" lay-verify="required" class="layui-textarea" style="resize:none;width: 560px;" maxlength="300">${tenant.models!'contacts'}</textarea>
				</div>
			</div>
		</div>
</div>
</div>



<div class="layui-form-button">
	<div class="layui-button-block">
		<button class="layui-btn" lay-submit lay-filter="formDemo">立即提交</button>
		<button type="reset" class="layui-btn layui-btn-primary">重置</button>
	</div>
</div>
</form>
</div>

<script type="text/javascript">
	//Demo
	layui.use('form', function(){
		var form = layui.form;
		form.render(); //更新全部
		form.verify({
			repass: function(value){
				if(value != $('#password').val()){
					return '两次输入的密码不一致，请确认';
				}
			},
			tenantcode: function(value){
				var text = /^[0-9a-zA-Z]+$/
				console.log($('#tenantcode').val());
				if(!text.test($('#tenantcode').val())){
					return '租户ID只能为英文、数字 和两者组合！';
				}
			}
		});
		form.on('select(province)', function(data){
			var el = $(data.elem).find("option:selected");
			var p = el.attr("value");
			$("input[name='provinceText']").val(el.html());
			loadURL('/res/dic.html?id='+p+"&name=city&attr=&style=width:100px;display:inline-block;&defaultname=&vkey=id&vvalue=name&isSelect2=true" , '#c_city',function(){form.render("select");$("#city").hide()});
		});
		form.on('select(city)', function(data){
			var el = $(data.elem).find("option:selected");
			var p = el.attr("value");
			$("input[name='cityText']").val(el.html());
			loadURL('/res/dic.html?id='+p+"&name=area&attr=&style=width:100px;display:inline-block;&defaultname=&vkey=id&vvalue=name&isSelect2=true" , '#c_country',function(){form.render("select");$("#area").hide()});
		});
		form.on('select(area)', function(data){
			var el = $(data.elem).find("option:selected");
			$("input[name='countryText']").val(el.html());
		});
	});
</script>